const json  = {
    behaviours: [
        {
            name: "Transform", properties: {
                x: 0, y: 0, rotation: 0,
            }
        }
    ],
    children: [
        {
            behaviours: [
                {
                    name: "Transform", properties: {
                        x: 100, y: 0, rotation: 45, scaleX: 1, scaleY: 1, alpha: 0.5
                    }
                },
                {
                    name: "BitmapRenderer", properties: {
                        source: 'assets/icon.jpg'
                    }
                },
                {
                    name: "Move", properties: {
                        speedX: 60
                    }
                },
                {
                    name: "DisableOnClick"
                }
            ],
        },
        {
            behaviours: [
                { name: 'Transform', properties: { x: 300 } },
                { name: 'TextRenderer', properties: { color: '#ff0000', text: '王泽' } }
            ]
        },
    ]
}

function visit(json){
    const result = {};
    result.type = json.type;
    result.behaviours = json.behaviours || [];
    if (json.properties){
            const transform ={ name:"Transform",properties:{}};
            transform.properties.x = json.properties.x || 0;
            transform.properties.y = json.properties.y || 0;
            result.behaviours.push(transform);

    }
    return result;
}

// const result = visit(json)
const fs = require('fs');
fs.writeFileSync('scripts/1.json',JSON.stringify(json,null,'\t'),'utf-8')